// xc_lshop/shop/order/com/orderinfortop.js
Component({
  options: {
    addGlobalClass: true,
    multipleSlots: true
  },
  /**
   * 组件的属性列表
   */
  properties: {
    basicurl: String,
    xcmodel: Object,
    themconfig: Object,
  },

  /**
   * 组件的初始数据
   */
  data: {
    statusdata: {
      "-6": {
        name: "拒绝退款",
        text: "抱歉您的订单被拒绝退款",
        icon: "orderinfor-refundfail"
      },
      "-5": {
        name: "申请退款",
        text: "请稍等，您的订单正在处理...",
        icon: "orderinfor-refunding"

      },
      "-4": {
        name: "已退款",
        text: "退款金额已原路返回至付款账户",
        icon: "orderinfor-refundsuccess"

      },
      "-7": {
        name: "退款中",
        text: "等待退款",
        icon: "orderinfor-refundsuccess"

      },
      "-8": {
        name: "退款失败",
        text: "等待重新退款",
        icon: "orderinfor-refundsuccess"

      },
      "-3": {
        name: "已取消",
        text: "您已取消订单",
        icon: "orderinfor-cancel"

      },
      "-2": {
        name: "未付款",
        text: "付款剩余时间",
        icon: "orderinfor-unpay"

      },
      "-1": {
        name: "拼团失败",
        text: "啊哦~拼团失败了",
        icon: "orderinfor-cancel"

      },
      "1": {
        name: "待发货",
        text: "请耐心等待商家发货",
        icon: "orderinfor-undeliver"
      },
      "2": {
        name: "拼团成功【待发货】",
        text: "请耐心等待商家发货",
        icon: "orderinfor-undeliver"

      },
      "3": {
        name: "拼团中",
        text: "快去邀请好友参团吧",
        icon: "orderinfor-grouping"

      },
      "4": {
        name: "拼团中【已满员】",
        text: "请稍等，还有团员未支付~",
        icon: "orderinfor-grouping"

      },
      "5": {
        name: "待收货",
        text: "您的快递正在赶来...",
        icon: "orderinfor-unreceived"

      },
      "6": {
        name: "待取货",
        text: "请在收到提货通知24小时内，到指定提货门店凭提货人姓名/电话，进行提货",
        icon: "orderinfor-getting"

      },
      "7": {
        name: "待评价",
        text: "亲，快来评价吧！",
        icon: "orderinfor-uncomment"

      },
      "8": {
        name: "已完成",
        text: "交易已完成",
        icon: "orderinfor-finish"

      },
      "9": {
        name: "待配送",
        text: "您的商品已到达团点中，正在等待人员派送",
        icon: "orderinfor-getting"

      },
      "10": {
        name: "配送中",
        text: "您的商品正在派送中...",
        icon: "orderinfor-getting"

      },
      "11": {
        name: "已售出",
        text: "您的售出金额和快递费用将退至您的红包补贴，请查收",
        icon: "orderinfor-finish"
      },
      "12": {
        name: "邀请中",
        text: "请在规定时间内赚满",
        icon: "orderinfor-undeliver"
      },
      "13": {
        name: "邀请失效",
        text: "已失效，正在退款中",
        icon: "orderinfor-undeliver"
      },


    }
  },
  ready() {},
  /**
   * 组件的方法列表
   */

  methods: {
    set(xcmodel) {
      console.log("this.data.xcmodel")
      console.log(xcmodel)
      this.setData({
        xcmodel: xcmodel
      })
      var status = xcmodel.status;
      var ordertype = xcmodel.ordertype;
      var groupstatus = xcmodel.groupstatus;
      var refundstatus = xcmodel.refundstatus;
      var iscomment = xcmodel.iscomment;
      var clubstatus = xcmodel.clubstatus;
      var distributionmode = xcmodel.distributionmode;
      var taskinfo = xcmodel.taskinfo;

      // var message = ["", ""];
      var orderinfostatus = 0;
      console.log("refundstatus")
      console.log(refundstatus)
      switch (refundstatus) {
        case "0": {
          orderinfostatus = -7
          break
        }
        case "1": {
          orderinfostatus = -4
          break
        }
        case "2": {
          orderinfostatus = -5
          break
        }
        case "3": {
          orderinfostatus = -6
          break
        }
        case "4": {
          orderinfostatus = -8
          break
        }
      }
      if (orderinfostatus == 0) {
        switch (status) {
          case "-3": {

            orderinfostatus = -3
            break;
          }
          case "-1": {
            orderinfostatus = -2

            break;
          }
          case "1": {
            if (ordertype == 2) {
              if (groupstatus == 1) {
                orderinfostatus = 3
              } else if (groupstatus == 2) {
                orderinfostatus = 4
              } else if (groupstatus == 3) {
                orderinfostatus = 2
              } else if (groupstatus == -1) {
                orderinfostatus = -1
              }
            } else if (ordertype == 6) {
              if (groupstatus == 1) {
                orderinfostatus = 3
              } else if (groupstatus == 2) {
                orderinfostatus = 4
              } else if (groupstatus == 3) {
                orderinfostatus = 2
              } else if (groupstatus == -1) {
                orderinfostatus = -1
              }
            } else if (ordertype == 15) {
              if (taskinfo) {

                if (taskinfo.taskstatus == 1) {

                  if (this.shutdown(taskinfo.validityend) < 0) {

                    orderinfostatus = 13

                  } else {

                    orderinfostatus = 12

                  }


                } else if (taskinfo.taskstatus == 2) {
                  orderinfostatus = 1
                }
              }
            } else {
              orderinfostatus = 1
            }
            break;
          }
          case "4": {
            orderinfostatus = 5
            break;
          }
          case "6": {

            if ((distributionmode & 16) == 16) {
              if (clubstatus == 3) {
                orderinfostatus = 10

              } else {
                orderinfostatus = 9

              }
            } else {
              orderinfostatus = 6

            }



            break;
          }
          case "9": {
            if (ordertype == 5 || ordertype == 7) {
              orderinfostatus = 8
            } else {
              if (iscomment == -1) {
                orderinfostatus = 7
              } else {
                orderinfostatus = 8

              }
            }

            break;
          }
          case "10": {
            orderinfostatus = 11
            break;
          }
        }
      }


      console.log("orderinfostatus")
      console.log(orderinfostatus)

      this.setData({
        orderinfostatus: orderinfostatus
      })
      // return orderinfostatus;
    },
    shutdown(val) {
      return val * 1000 - Date.parse(new Date())
    }

  }
})